<?php
class DepositsController extends AppController {

	var $name = 'Deposits';
	//var $helpers = array('Html', 'Form', 'Ajax', 'Javascript');
	//var $uses = array('Deposit', 'Event');

	function index() {
		$this->Deposit->recursive = 0;
		$this->set('deposits', $this->paginate());
	}
	
	function view($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Deposit', true), array('action'=>'index'));
		}
		$this->set('deposit', $this->Deposit->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Deposit->create();
			if ($this->Deposit->save($this->data)) {
				$this->flash(__('Deposit saved.', true), array('action'=>'index'));
			} else {
			}
		}
		$tournaments = $this->Deposit->Tournament->find('list');
		$this->set(compact('tournaments'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->flash(__('Invalid Deposit', true), array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Deposit->save($this->data)) {
				$this->flash(__('The Deposit has been saved.', true), array('action'=>'index'));
			} else {
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Deposit->read(null, $id);
		}	
		$tournaments = $this->Deposit->Tournament->find('list');
		$this->set(compact('tournaments'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->flash(__('Invalid Deposit', true), array('action'=>'index'));
		}
		if ($this->Deposit->del($id)) {
			$this->flash(__('Deposit deleted', true), array('action'=>'index'));
		}
	}

}
?>